<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 系统管理&gt;&gt; 岗检与部门映射关系
</div>

<%
{
%>
<div class="tt">管理岗检与部门关系</div>
<div class="content">
	<div class="apptab">
	<table align="center" border="0" width="700" cellpadding="0"
		cellspacing="0">
		<tr>
			<td  class="td1" height="35">				
				<span style="margin-left: 30px">岗检：</span>
				<span id="roleSelectSpan">
				<%@include file="postcheck_select/postcheck_select2_section.jsp" %>
				</span>
			</td>
			<td class="td1" height="35">
				<span style="margin-left: 30px">一级单位：</span>
				<span id="depart1SelectSpan">
				<%@include file="depart_select/depart1_select2_section.jsp" %>
				</span>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="td1" align="center">
				<input type="button" value="添加" onclick="addMapping()" />
			</td>
		</tr>
	</table>
	</div>
	<div class="apptab" id="problemBrowseListTD">
		<%@include file="department1_postcheck_list.jsp"%>
	</div>
	
</div>
<script type="text/javascript">
function selectDepart1() {
	//var depart1ID = getElementValueByID('depart1');
	//var postcheckID = getElementValueByID('postcheck');
	//loadPageSection(
	//		'<%=request.getContextPath()%>/admin/department1_postcheck.jsp', 
	//		'mainContentDiv', 
	//		{
	//			depart1ID: depart1ID, 
	//			postcheckID: postcheckID
	//		}, 
	//		true
	//); 
}

function selectPostcheck(){
	//var depart1ID = getElementValueByID('depart1');
	var postcheckID = getElementValueByID('postcheck');
	loadPageSection(
			'<%=request.getContextPath()%>/admin/department1_postcheck.jsp', 
			'mainContentDiv', 
			{
				//depart1ID: depart1ID,
				postcheckID: postcheckID
			}, 
			true
	); 
}

function addMapping(){
	var depart1ID = getElementValueByID('depart1');
	var postcheckID = getElementValueByID('postcheck');

	if(depart1ID == null || depart1ID == '' || depart1ID == 0){
		$.dialog.alert("请选择部门");
		return;
	}

	if(postcheckID == null || postcheckID == '' || postcheckID == 0){
		$.dialog.alert("请选择岗检");
		return;
	}
	
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'add_department1_postcheck_process.jsp',
		data:{			
			depart1ID: depart1ID,
			postcheckID: postcheckID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {		
						loadPageSection(
								'<%=request.getContextPath()%>/admin/department1_postcheck.jsp', 
								'mainContentDiv', 
								{
									//depart1ID: depart1ID, 
									postcheckID: postcheckID
								}, 
								true
						); 				
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});	
}




function deleteMapping(depart1ID, postcheckID) {
	//var depart1IDSelected = getElementValueByID('depart1');
	var postcheckIDSelected = getElementValueByID('postcheck');
	
$.dialog.confirm('您确认修改吗？', function(){
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'delete_department1_postcheck_process.jsp',
		data:{			
			depart1ID: depart1ID,
			postcheckID: postcheckID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {					
					$.dialog('删除成功！', function() { 
						loadPageSection(
								'<%=request.getContextPath()%>/admin/department1_postcheck.jsp', 
								'mainContentDiv', 
								{
									//depart1ID: depart1IDSelected, 
									postcheckID: postcheckIDSelected
								}, 
								true
						); 
					});					
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
});
}
</script>
<%
}
%>

